/**
 * 详情对话框
 */
var ToolExpressScanInfoDlg = {
    data: {
        state: "",
        waveId: "",
        orderNumber: "",
        userId: "",
        userName: "",
        v1: "",
        v2: ""
    }
};
/**
 * 详情对话框
 */
var StoragePutSingleInfoDlg = {
    data: {
    	positionNumber: "",
		positionId:""
    }
};

layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
		let ids = []
		let shiftNums = []
        for (var i = 0; i < parent.inputlist.length; i++) {
			ids.push(parent.inputlist[i].id)
			shiftNums.push(parent.inputlist[i].shiftNum)
		}
        var ajax = new $ax(Feng.ctxPath + "/toolStorageStock/btnShift?ids="+ids+"&shiftNums="+shiftNums, function (data) {
    		if (data.success) {
				parent.submit = 1
            	Feng.success("操作成功！");
            	var Indexs = parent.layer.getFrameIndex(window.name);
                parent.layer.close(Indexs);
			} else {
                Feng.error("操作失败！"+data.message);
			}
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //查询库区
    form.on('select(warehouseId)',function(){
        $("#areaId").empty();
        $.ajax({
            url:Feng.ctxPath + '/basicArea/Querylist',
            dataType:"json",   //返回格式为json
            async: false,
            data:{"areaWarehouseId":$("#warehouseId").val()},    //参数值
            type:"post",   //请求方式
            success:function(data){
                if(data.length>0){
                    var str = "<option value=''>请选择</option>";
                    $.each(data,function(key,value){
                        str += "<option value='"+value.id+"'>"+value.areaNumber+"</option>";
                    });
                    $("#areaId").html(str);
                }
            }
        });
        form.render('select');
    });

    //点击选择库位
    $('#selectposition').click(function () {
        layer.open({
            type: 2,
            title: '选择库位',
            area: ['700px', '400px'],
            content: Feng.ctxPath + '/storageStock/toPositionStock?positionAreaId='+$("#areaId").val()+'&warehouseId='+$("#warehouseId").val(),
            end: function () {
                $("#positionNumber").val(StoragePutSingleInfoDlg.data.positionNumber);//库位编号
            }
        });
    });

    //返回按钮
    $("#backupPage").click(function () {
    	var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

});